package org.administer.pojo;

import java.io.Serializable;
import java.sql.Date;
import java.util.Iterator;
import java.util.List;

public class CrmUser implements Serializable {
    private int id;
    private String username;
    private String password;
    private String salt;
    private String phone;
    private String sex;
    private String address;
    private String picture;
    private Date birthday;
    private Integer available;
    private Integer roleid;
    private List<CrmRole> roles;//用户拥有的角色列表
    private String roleString; //角色字符串
    private CrmRole crmRole;    //角色表
    public Integer getRoleid() {
        return roleid;
    }

    public void setRoleid(Integer roleid) {
        this.roleid = roleid;
    }

    public CrmRole getCrmRole() {
        return crmRole;
    }

    public void setCrmRole(CrmRole crmRole) {
        this.crmRole = crmRole;
    }

    public String getRoleString() {
        if(this.roles == null || this.roles.size() == 0){
            this.roleString = "-";
            return roleString;
        }
        StringBuilder sb = new StringBuilder();
        Iterator<CrmRole> it = this.roles.iterator();
        for(;;){
            sb.append(it.next().getRolename());
            if(!it.hasNext()){
                this.roleString = sb.toString();
                break;
            }
            sb.append(",");

        }
        return roleString;
    }

    public List<CrmRole> getRoles() {
        return roles;
    }

    public void setRoles(List<CrmRole> roles) {
        this.roles = roles;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Integer getAvailable() {
        return available;
    }

    public void setAvailable(Integer available) {
        this.available = available;
    }
}
